#include<bits/stdc++.h>
using namespace std;

int d[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

int main()
{
	int y, num;
	cin>>y>>num;
	if(y % 4 == 0 && y % 100 || y % 400 == 0)
		d[2] = 29;
		
	int cnt = 0;
	for(int i = 1;i <= 12;i++)
	{
		for(int j = 1;j <= d[i];j++)
		{
			cnt++;
			if(cnt == num)
			{
				cout<<i<<"."<<j;
				return 0;
			}
		}
	}
    return 0;
}

